﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using ORS.BLL;

namespace ORS.Web
{
    public partial class Login : System.Web.UI.Page
    {
        Authentication ivk_Authentication= new Authentication();   


                
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Visible = false;
            Label2.Visible = false;
            Label3.Visible = false;
        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        protected void TextPassword_TextChanged(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string sAdminID = this.tbxuserID.Text;
            string sAdminPWD = this.TextPassword.Text;
            string stablename = "tb_admin";
            int getnum=0;
            getnum = ivk_Authentication.IsUserExisting(stablename, sAdminID, sAdminPWD);
            switch (getnum)
                {
                   case 1:
                        Label1.Visible=true;break;
                   case 2:
                        Label2.Visible=true;break;
                   case 4:
                        Session["Admim_IDS"]=sAdminID;Response.Redirect("Index_Adm.aspx");break;
                   default:
                        break;
                }

        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            string sAdminID = this.tbxuserID.Text;
            string sAdminPWD = this.TextPassword.Text;
            string stablename = "tb_userlist";
            int getnum = 0;
            processopr ivk_processopr = new processopr();
            getnum = ivk_Authentication.IsUserExisting(stablename, sAdminID, sAdminPWD);
            switch (getnum)
            {
                case 1:
                    Label1.Visible=true;break;
                case 2:
                    Label2.Visible=true;break;
                case 3:
                    Label3.Visible=true;break;
                case 4:
                    pageChange(); break;
                default:
                    break;
            }
        }

        void pageChange()
        {
            string sAdminID = this.tbxuserID.Text;
            roleselect roleSelect = new roleselect();
            string rolename = roleSelect.SelectRole(sAdminID).Trim();
            if (rolename == "作者")
            {
                Session["userid"] = sAdminID;
                Response.Redirect("Index_User.aspx");
            }
            if (rolename == "审稿人")
            {
                Session["reviewerid"] = sAdminID;
                Response.Redirect("Review_Mainpage.aspx");
            }
        }
    }
}